/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 29489
 * Date: 2023-03-04
 * Time: 16:50
 */
import java.util.Scanner;
//java中没有全局变量
//int M = 10;
public class Main1 {
    //    public static void main(String[] args){
//        System.out.println(Integer.MAX_VALUE);
//        System.out.println(Integer.MIN_VALUE);
//        //java中，局部变量必须初始化
////        int a;
////        System.out.println(a);
////        赋值不能超过变量类型的范围
////        int c = 2147483648；
//
//
//    }
//    public static void Swap(int arr[], int left, int right){
//        int tmp = arr[left];
//        arr[left] = arr[right];
//        arr[right] = tmp;
//    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int Array[] = null;
        Array = new int[n];

        for (int i = 0; i < n; i++) {
            Array[i] = sc.nextInt();
        }
        int adjust_num = sc.nextInt();

        for (int i = 0; i < adjust_num; i++) {
//            int ele[] = null;
//            ele = new int[2];

//            String str = sc.nextLine();
//            String s[] = str.split(" ");
//            for (int j = 0; j < s.length; j++) {
//                ele[j] = Integer.parseInt(s[j]);
//            }
            int x = sc.nextInt();
            int y = sc.nextInt();
            Swap(Array, x-1, y-1);
        }
        for (int i = 0; i < n; i++) {
            if (i < n - 1)
                System.out.print(Array[i] + " ");
            else
                System.out.println(Array[i]);
        }
    }

    public static void Swap(int arr[], int left, int right) {
        int tmp = arr[left];
        arr[left] = arr[right];
        arr[right] = tmp;
    }
}

